package by.dezhits.makeanote.adapter;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import by.dezhits.makeanote.R;
import by.dezhits.makeanote.content.contract.NotesContract;

public class NotesCursorAdapter extends CursorAdapter{
	
	

	public NotesCursorAdapter(Context context, Cursor c) {
		super(context, c, false);
	}

	@Override
	public void bindView(View oldView, Context context, Cursor cursor) {
		TextView tvTitle = (TextView) oldView.findViewById(R.id.tv_note_title);
		TextView tvDate = (TextView) oldView.findViewById(R.id.tv_note_date);
		String title = cursor.getString(cursor.getColumnIndex(NotesContract.NotesColumns.TITLE));
		String date = cursor.getString(cursor.getColumnIndex(NotesContract.NotesColumns.DATE));
		tvTitle.setText(title);
		tvDate.setText(date);

}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
		View view = View.inflate(context, R.layout.adapter_note, null);
		return view;
	}

}
